import javax.annotation.concurrent.ThreadSafe;

@ThreadSafe
public class read_write_race {

  private int mBalance = 0;

  public void deposit(int amount) {
    if (amount > 0) {
      mBalance += amount;
    }
  }

  public int withdraw(int amount) {
    if (amount >= 0 && mBalance - amount >= 0) {
      mBalance -= amount;
      return mBalance;
    } else {
      return 0;
    }
  }

  public int getBalance() { return mBalance; }
}
